<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/TX">
		<xsl:for-each select="TX_BODY">
			<infopost-request>
				<request-head>
					<xsl:for-each select="ENTITY/COM_ENTITY">
						<insu-id>
							<xsl:value-of select="Ins_Co_ID" />
						</insu-id>
						<trans-id>
							<xsl:value-of select="SvPt_Jrnl_No" />
						</trans-id>
						<post>
							<xsl:value-of select="CCBIns_ID" />
						</post>
						<agency-hand>
							<xsl:value-of select="CCB_EmpID" />
						</agency-hand>
						<!-- 交易发起渠道编号 -->
						<column12>
							<xsl:value-of select="TXN_ITT_CHNL_ID" />
						</column12>
						<!-- 交易发起渠道类别 -->
						<column13>
							<xsl:value-of select="TXN_ITT_CHNL_CGY_CODE" />
						</column13>
					</xsl:for-each>
					<bank>002</bank>
					<area>002</area>
					<branch />
					<authorized>root</authorized>
					<trans-type>102</trans-type>

					<xsl:for-each select="/TX/TX_HEADER">
						<trans-date>
							<xsl:value-of select="substring(SYS_REQ_TIME,1,8)" />
						</trans-date>
						<trans-time>
							<xsl:value-of select="substring(SYS_REQ_TIME,9,6)" />
						</trans-time>
						<!-- 发起方安全节点编号 -->
						<column6>
							<xsl:value-of select="SYS_REQ_SEC_ID" />
						</column6>
						<!-- 全局事件跟踪号 -->
						<column7>
							<xsl:value-of select="SYS_EVT_TRACE_ID" />
						</column7>
						<!-- 子交易序号 -->
						<column8>
							<xsl:value-of select="SYS_SND_SERIAL_NO" />
						</column8>
					</xsl:for-each>

					<xsl:for-each select="/TX/TX_BODY/COMMON/FILE_LIST_PACK">
						<!-- 文件个数 -->
						<column9>
							<xsl:value-of select="FILE_NUM" />
						</column9>
						<!-- 文件名 -->
						<column10>
							<xsl:value-of select="FILE_NAME" />
						</column10>
						<!-- 文件路径 -->
						<column11>
							<xsl:value-of select="FILE_PATH" />
						</column11>
					</xsl:for-each>
				</request-head>
				<request-newbiz>
					<xsl:for-each select="ENTITY/APP_ENTITY">
						<request-underwriting>
							<application>
								<policy-holder>
									<real-name>
										<xsl:value-of select="Plchd_Nm" />
									</real-name>
									<certi-type>
										<xsl:call-template name="TlCertiType">
											<xsl:with-param name="CertiTypeValue" select="Plchd_Crdt_TpCd" />
										</xsl:call-template>
									</certi-type>
									<certi-code>
										<xsl:value-of select="Plchd_Crdt_No" />
									</certi-code>
									<certi-start-date>
										<xsl:value-of select="translate(string(Plchd_Crdt_EfDt),'-','')" />
									</certi-start-date>
									<certi-end-date>
										<xsl:value-of select="translate(string(Plchd_Crdt_ExpDt),'-','')" />
									</certi-end-date>
									<xsl:choose>
										<xsl:when test="Plchd_Nat_Cd = ''">
											<nationality />
										</xsl:when>
										<xsl:otherwise>
											<nationality>37</nationality>
										</xsl:otherwise>
									</xsl:choose>
								</policy-holder>
								<account-type>7</account-type>
								<bank-code>201</bank-code>
								<!--首期付款方式 -->
								<pay-mode>
									<xsl:call-template name="TlPbInsuPayMode">
										<xsl:with-param name="PbInsuPayMode" select="InsPrem_PyMd_Cd" />
									</xsl:call-template>
								</pay-mode>
								<bank-account>
									<xsl:value-of select="CCB_AccNo" />
								</bank-account>
							</application>
						</request-underwriting>
						<request-policy-issue>
							<apply-code>
								<xsl:value-of select="Ins_BillNo" />
							</apply-code>
							<premium>
								<xsl:value-of select="Ins_PyF_Amt" />
							</premium>
							<uw-trans-id>
								<xsl:value-of select="Ins_Co_Jrnl_No" />
							</uw-trans-id>
						</request-policy-issue>
					</xsl:for-each>
				</request-newbiz>
			</infopost-request>
		</xsl:for-each>
	</xsl:template>

	<!--首期付款方式 -->
	<xsl:template name="TlPbInsuPayMode">
		<xsl:param name="PbInsuPayMode" />
		<xsl:choose>
			<xsl:when test="$PbInsuPayMode=1">
				3
			</xsl:when>
			<xsl:when test="$PbInsuPayMode=2">
				3
			</xsl:when>
			<xsl:when test="$PbInsuPayMode=3">
				3
			</xsl:when>
			<xsl:when test="$PbInsuPayMode=0">
				94
			</xsl:when>
			<xsl:otherwise>
				1
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<!--证件类型 -->
	<xsl:template name="TlCertiType">
		<xsl:param name="CertiTypeValue" />
		<xsl:choose>
			<!--身份证 -->
			<xsl:when test="$CertiTypeValue='1010'">
				1
			</xsl:when>
			<!-- 临时居民身份证 -->
			<xsl:when test="$CertiTypeValue='1011'">
				1
			</xsl:when>
			<!--军人身份证件 -->
			<xsl:when test="$CertiTypeValue='1020'">
				2
			</xsl:when>
			<!--外国护照 -->
			<xsl:when test="$CertiTypeValue='1052'">
				3
			</xsl:when>
			<!--港澳居民往来内地通行证 -->
			<xsl:when test="$CertiTypeValue='1070'">
				6
			</xsl:when>
			<!--户口簿 -->
			<xsl:when test="$CertiTypeValue='1040'">
				7
			</xsl:when>
			<!--武警身份证件 -->
			<xsl:when test="$CertiTypeValue='1030'">
				8
			</xsl:when>
			<!--其他证件（对公） -->
			<xsl:when test="$CertiTypeValue='2999'">
				9
			</xsl:when>
			<!--台湾居民来往大陆通行证 -->
			<xsl:when test="$CertiTypeValue='1080'">
				9
			</xsl:when>
			<!--外国人居留证 -->
			<xsl:when test="$CertiTypeValue='1120'">
				9
			</xsl:when>
			<!--其他证件（个人） -->
			<xsl:when test="$CertiTypeValue='1999'">
				9
			</xsl:when>
			<!--营业执照 -->
			<xsl:when test="$CertiTypeValue='2010'">
				9
			</xsl:when>
			<!--组织机构代码证 -->
			<xsl:when test="$CertiTypeValue='2020'">
				9
			</xsl:when>
			<!--社会团体法人登记证书 -->
			<xsl:when test="$CertiTypeValue='2030'">
				9
			</xsl:when>
			<!--事业法人登记证书 -->
			<xsl:when test="$CertiTypeValue='2040'">
				9
			</xsl:when>
			<!--税务登记证 -->
			<xsl:when test="$CertiTypeValue='2090'">
				9
			</xsl:when>
			<xsl:when test="$CertiTypeValue=''">

			</xsl:when>
			<xsl:otherwise>
				CODE_NOT_EXIST
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
